package com.bbs.domain;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.MappedSuperclass;

/**
 * AbstractAuthority entity provides the base persistence definition of the
 * Authority entity. @author MyEclipse Persistence Tools
 */
@MappedSuperclass
public abstract class AbstractAuthority implements java.io.Serializable {

	// Fields

	private Integer id;
	private String name;
	private Set<Role> roles = new HashSet<Role>(0);

	// Constructors

	/** default constructor */
	public AbstractAuthority() {
	}

	/** full constructor */
	public AbstractAuthority(String name, Set<Role> roles) {
		this.name = name;
		this.roles = roles;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name")
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "authorities")
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}